#!/bin/bash
# mod for multi-submit pet tests on theta in debug queue
if [ `./xmlquery --value MACH` == theta ]&&
   [ `./xmlquery --value JOB_QUEUE --subgroup case.test` == debug-cache-quad ]; then
  echo "theta pet test in debug queue"
  # get number of nodes
  nodes=$(./preview_run | grep nodes | grep -o '[[:digit:]]*')
  echo "nodes=$nodes"
  if [ $nodes -lt 128 ]; then
    # increase ntasks to get into production queue: 128 nodes, 64 mpi/node
    ./xmlchange --id NTASKS --val 8192
    echo "new NTASKS=8192"
  fi
  ./xmlchange --id JOB_QUEUE --val default
  echo "new queue=default"
  # lnd on ne4 grid can't run with more than 128 tasks
  if [ `./xmlquery --value GRID | grep -Eo 'a%ne4np4_l%ne4.+' | wc -l` -gt 0 ]; then
    echo "ne4 grid, setting NTASKS_LND to 128"
    ./xmlchange --id NTASKS_LND --val 128
    echo "ne4 grid, setting NTASKS_ATM to 96"
    ./xmlchange --id NTASKS_ATM --val 96
  fi
fi
